<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/10/25
 * Time: 9:57
 */

namespace Wapv2\Controller;


use Think\Controller;
use Think\Model;
use Wapv2\Model\AutumnWanderModel;

/**
 * Class AutumnWanderController
 * @package Wapv2\Controller
 * @User: yfl
 * @Time: 2017年10月25日 09:58:12
 * @description: 秋游活动
 */
class AutumnWanderController extends Controller
{
    private $appId = "wxa75db3ff18ee9c04";

    private $appSec = "1f6eb1a8d79c662158df86848cbfb819";

    private $testComPassId = 41;//测试转盘数据 id

    private static $startTime = '2017-10-25 10:00:00'; //开始时间

    private static $endTime = '2017-11-09 15:00'; //结束时间

//    private static $testOpenId = 'oGbS-tz4tqGWjYXrX-mQ6gA9nd0M'; //测试的openid
    private static $testOpenId ; //测试的openid

    private static $msg = array(
        '0' => '请求错误!',
        '1' => '投票机会已经用完，谢谢参与',
        '2' => '投票成功,抽奖次数+1!',
        '3' => '投票失败！',
        '4' => '投标成功，获取抽奖机会失败！',
        '5' => '投票的机会减少一次失败',
        '6' => '重新获取openID',
        '7' => '保存活动记录失败',
        '8' => '给同一个酒店一天只可以投一次票',
        '9' => '保存抽奖信息失败',
        '10' => '抽中实物奖品,提交个人信息',
        '11' => '没有中奖,谢谢参与,明天在来试试!',
        '12' => '提交信息成功',
        '13' => '提交信息失败',
        '14' => '抽奖失败',
        '15' => '已经中过奖品，不能再次中奖',
        '16' => '先去投票获取抽奖机会,剩余票数',
        '17' => '今天的抽奖机已经用完,请明天再来！',
        '18' => '今天还没有参加,回到首页',
        '19' => '今天的投票机已经用完,请明天再来！'
    );

    private static $pollNum = 5; //投票的机会

    private $openId;//微信OpenID

    private static $prizeIdArr = array(1, 2, 3, 4, 5); //实物奖品ID序号

    private $prizeConfigArr; // 奖品配置信息

    private $prizeId;//随机获取的奖品的ID序号

    private $randPrizeArr; //当前中奖的信息

    protected $todayWhere = 'TO_DAYS(FROM_UNIXTIME(create_time)) = TO_DAYS(NOW())';

    public function __construct()
    {
        parent::__construct();
        $this->init();
    }

    /**
     * @User: yfl
     * @Time: 2017年10月25日 08:54:57
     * @description:活动初始化
     */
    private function init()
    {
        if ($_SERVER['REQUEST_TIME'] < strtotime(self::$startTime)) {
            header("Content-type:text/html;charset=utf-8");
            exit('活动尚未开始...！');
        }
        if ($_SERVER['REQUEST_TIME'] > strtotime(self::$endTime)) {
            header("Content-type:text/html;charset=utf-8");
            exit('活动结束咯...！');
        }
        $openId = htmlspecialchars(I("get.openid", self::$testOpenId), ENT_QUOTES);
        if (session("?AutumnWander_openId") == true || !empty($openId)) {
            $this->openId = !empty($openId) ? $openId : session("AutumnWander_openId");
        } else {
            if (empty($_GET['code'])) {
                $redirect_uri = "http://" . $_SERVER['HTTP_HOST'] . "/Wapv2/AutumnWander/getFsInfo";
                redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . $this->appId . "&redirect_uri=" . urlencode($redirect_uri) . "&response_type=code&scope=snsapi_userinfo&state=snsapi_userinfo#wechat_redirect");
            }
        }

    }

    /**
     * @User: yfl
     * @Time: 2017年10月30日 11:31:59
     * @description:开始首页
     */
    public function index()
    {
        $this->display('AutumnWander/index');
    }

    /**
     * @User: yfl
     * @Time: 2017年10月25日 10:08:20
     * @description: 获取用户的信息
     */
    public function getFsInfo()
    {
        $code = $_GET['code'];
        $link = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $this->appId . "&secret=" . $this->appSec . "&code=" . $code . "&grant_type=authorization_code";
        $resJson = curlSend($link);
        $resArr = json_decode($resJson, true);

        if ($_GET['state'] == "snsapi_userinfo") {
            $link = "https://api.weixin.qq.com/sns/userinfo?access_token=" . $resArr['access_token'] . "&openid=" . $resArr['openid'] . "&lang=zh_CN";
            $resJson = curlSend($link);
            $resArr = json_decode($resJson, true);
        }
//        echo 'success';
        $this->redirect("/Wapv2/AutumnWander/activeIndex/?openid=" . $resArr["openid"]);
    }

    /**
     * @User: yfl
     * @Time: 2017年10月25日 10:09:48
     * @description: 活动首页 获取参与用户的openID并保存
     */
    public function activeIndex()
    {
        $autumnWanderModel = new AutumnWanderModel();
        if (!isset($this->openId)) {
            $domain = $_SERVER['HTTP_HOST'];
            $redirect_uri = "http://" . $domain . "/Wapv2/AutumnWander/getFsInfo";
            redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . $this->appId . "&redirect_uri=" . urlencode($redirect_uri) . "&response_type=code&scope=snsapi_userinfo&state=snsapi_userinfo#wechat_redirect");
        } else {
            if (session("?AutumnWander_openId") == false) {
                session("AutumnWander_openId", $this->openId);
            }
        }
        $where = array('open_id' => $this->openId, "TO_DAYS(FROM_UNIXTIME(create_time)) = TO_DAYS(NOW())");
        $res = $autumnWanderModel->handelPartInData($where);
        if ($res == false) {
            exit('保存open_id 失败');
        }
        $field = 'a.id,a.name,a.photo_path,a.describe,a.poll_nums,a.hotel_photo_path,b.address';
        $exertInfoArr = $autumnWanderModel->getExertInfo(array(), $field);
        $this->assign('listArr', $exertInfoArr);
        $this->display("AutumnWander/activeIndex");
    }

    /**
     * @param string $id 酒店或者人的记录ID
     * @param int $type 1 给个人投票  2给酒店投票
     * @User: yfl
     * @Time:2017年10月25日 15:10:17
     * @description ajax投票
     */
    public function clickPollAjax()
    {
        if (!IS_AJAX || !IS_POST) exit('非法请求');
        $autumnWanderModel = new AutumnWanderModel();
        $type = htmlspecialchars(I('post.type', ''), ENT_QUOTES);
        $id = htmlspecialchars(I('post.id', ''), ENT_QUOTES);

        if ($type == '' || $id == '') $this->ajaxError(self::$msg[3]);
        if (!isset($this->openId)) $this->ajaxError(self::$msg['6'], -100); //这里返回要重新返回到首页获取openID
        $dataArr = $this->getPoll($this->openId, $autumnWanderModel);

        $hasPollNum = (int)$dataArr['poll']; //今天可以投票的数量

        if ($hasPollNum > 0 && $hasPollNum <= self::$pollNum) {
            //可以投票

            $objTable = '';
            if ((int)$type == 1) {
                $objTable = 'autumn_wander_person';//达人
            } elseif ((int)$type == 2) {
                $objTable = 'autumn_wander_hotel'; //酒店
            } else {
                $this->ajaxError(self::$msg[3], -300);
            }
            $res = $autumnWanderModel->pollGetLottoNum($id, $this->openId, $objTable, array('type' => $type));
            if ($res === -1) {
                $this->ajaxError(self::$msg[3], -301);
            } elseif ($res == -2) {
                $this->ajaxError(self::$msg[4], -400);
            } elseif ($res == -3) {
                $this->ajaxError(self::$msg[5], -500);
            } elseif ($res == -4) {
                $this->ajaxError(self::$msg[7], -700);
            } elseif ($res == -5) {
                $this->ajaxError(self::$msg[8], -800);
            } else {
                $this->ajaxSuccess(self::$msg[2], 200);
            }
        } else {
            //不可以投票投票的机会已经用完
            $this->ajaxError(self::$msg[1], -100);
        }
    }

    /**
     * @User: yfl
     * @Time: 2017年10月25日 16:16:02
     * @description:抽奖页面
     */
    public function lottoIndex()
    {
        $this->display("AutumnWander/lottoIndex");
    }

    /**
     * @User: yfl
     * @Time: 2017年10月30日 16:04:25
     * @description: 达人邮寄信息
     */
    public function exertWander()
    {
        $id = htmlspecialchars(I('get.id', '', 'intval'), ENT_QUOTES);
        if (is_numeric($id)) {
            $model = new Model();
            $resArr = $model
                ->table('wx_autumn_wander_person as a')
                ->field('a.id as exert_id,a.name,a.photo_path,a.hotel_photo_path,a.describe,a.describe,a.poll_nums as p_poll_nums,b.*')
                ->join('wx_autumn_wander_hotel as b ON a.hotel_id=b.id')
                ->where(array('a.id' => $id))
                ->find();
            $resArr['hidden_reside_imgs'] = $this->handelImg($resArr['hidden_reside_imgs']);
            $resArr['hidden_wander_imgs2'] = $this->handelImg($resArr['hidden_wander_imgs2']);
            $resArr['hidden_wander_imgs3'] = $this->handelImg($resArr['hidden_wander_imgs3']);
            $resArr['hidden_wander_imgs4'] = $this->handelImg($resArr['hidden_wander_imgs4']);
            $resArr['hidden_wander_imgs5'] = $this->handelImg($resArr['hidden_wander_imgs5']);
            $resArr['eat_imgs'] = $this->handelImg($resArr['eat_imgs']);


//            dump($resArr);
            $this->assign('data', $resArr);
            $this->display("AutumnWander/exertWander");
        }
    }

    /**
     * @param $str
     * @return array|string
     * @User: yfl
     * @Time: 2017年10月30日 17:01:28
     * @description:处理图片路径
     */
    private function handelImg($str)
    {
        if (!empty($str)) {
            return explode(',', substr($str, 0, (strlen($str) - 1)));
        } else {
            return '';
        }

    }

    /**
     * @User: yfl
     * @Time: 2017年10月30日 17:05:30
     * @description: 酒店排行
     */
    public function hotelRanking()
    {
        $model = new Model();
        $listArr=$model->table('wx_autumn_wander_hotel')->field('id,hotel_name,poll_nums,list_img')->order('poll_nums DESC')->select();
//        dump($listArr);
        $this->assign('listArr',$listArr);
        $this->display("AutumnWander/hotelRanking");
    }
    /**
     * @User: yfl
     * @Time: 2017年10月30日 17:03:59
     * @description:酒店奖励
     */
    public function hotelAward()
    {
        $this->display("AutumnWander/hotelAward");
    }

    /**
     * @User: yfl
     * @Time: 2017年10月30日 14:12:16
     * @description: ajax点击抽奖
     */
    public function clickLottoAjax()
    {
        if (!IS_AJAX || !IS_GET) exit('非法请求');

        $autumnWanderModel = new AutumnWanderModel();
        $where = array('open_id' => $this->openId, $autumnWanderModel->getTodayWhere());
        $todayUserInfoArr = $autumnWanderModel->getPartInToday($where);
        if (!empty($todayUserInfoArr)) {
            if ($todayUserInfoArr['lotto_num'] == 0) {
                //有票数 但没有抽奖机会 提示去投票
                if ($todayUserInfoArr['poll'] > 0 && $todayUserInfoArr['poll'] <= self::$pollNum) {
                    $this->ajaxError(self::$msg[16] . $todayUserInfoArr['poll'] . '票', -1600);
                } else {
                    if ($todayUserInfoArr['poll'] == 0) {
                        //没有票数 也没有抽奖机会 提示去改天再来
                        $this->ajaxError(self::$msg[17], -1700);
                    }
                }
            }
        } else {
            $this->ajaxError(self::$msg[18], -1800);
        }

        unset($where);
        $where = array('open_id' => $this->openId, array('prize_id' => array('in', self::$prizeIdArr)));
        $count = $autumnWanderModel->getPrizeRecodeNum($where);
        //验证是否已经中过奖
        $model = new Model();
        if ($count > 0) {
            $recode_id = $this->lottoRecodeWrite($model);
            if ($recode_id == false) {
                $this->ajaxError(self::$msg[9], -900);
            }
            $model->table('wx_autumn_wander_part_in')->where(array('open_id' => $this->openId, $this->todayWhere))->setDec('lotto_num'); //投票的机会减少一次
            $this->ajaxError(self::$msg[15], -1500);
            unset($where);
        }
        $resArr = $autumnWanderModel->getLottoConfigInfo(array('id' => $this->testComPassId));
        $this->prizeConfigArr = unserialize($resArr['prize']);
        $this->HandlePrize();
    }

    /**
     * @User: yfl
     * @Time:2017年10月26日 14:16:21
     * @description:按照概率处理奖品
     */
    private function HandlePrize()
    {
        //配置奖品在大转盘显示的位置
        foreach ($this->prizeConfigArr as $key => $value) {//6格
            switch ($key) {
                case 0:
                    $this->prizeConfigArr[$key]['min'] = 0;
                    $this->prizeConfigArr[$key]['max'] = 29;
                    break;
                case 1:
                    $this->prizeConfigArr[$key]['min'] = 30;
                    $this->prizeConfigArr[$key]['max'] = 89;
                    break;
                case 2:
                    $this->prizeConfigArr[$key]['min'] = 90;
                    $this->prizeConfigArr[$key]['max'] = 149;
                    break;
                case 3:
                    $this->prizeConfigArr[$key]['min'] = 150;
                    $this->prizeConfigArr[$key]['max'] = 209;
                    break;
                case 4:
                    $this->prizeConfigArr[$key]['min'] = 210;
                    $this->prizeConfigArr[$key]['max'] = 269;
                    break;
                case 5:
                    $this->prizeConfigArr[$key]['min'] = 270;
                    $this->prizeConfigArr[$key]['max'] = 330;
                    break;
                case 6:
                    $this->prizeConfigArr[$key]['min'] = 331;
                    $this->prizeConfigArr[$key]['max'] = 360;
                    break;
            }
        }
        //根据概率获取奖品及指针位置
        $proArr = array();
        foreach ($this->prizeConfigArr as $key => $value) {
            $proArr[$key] = $value['pro'];
        }
        if (!empty($proArr)) {
            $this->prizeId = $this->get_rand($proArr);
        } else {
            $this->ajaxError(self::$msg[14], -1400);
        }

        $this->randPrizeArr = $this->prizeConfigArr[$this->prizeId];

        $this->randPrizeArr['min'] = mt_rand($this->randPrizeArr['min'] + 7, $this->randPrizeArr['max'] - 7);

        //剩余奖品的数量
        $autumnWanderModel = new AutumnWanderModel();
        $this->verifyPrizeTotals($autumnWanderModel);
        //限制每天被抽中的上限
        if ($this->randPrizeArr['perDay'] != '') {
            $this->verifyPrizePerDay($autumnWanderModel);
        }
        $model = new Model();
        $recode_id = $this->lottoRecodeWrite($model);//保存抽奖记录
        if ($recode_id == false) {
            $this->ajaxError(self::$msg[9], -900);
        } else {
            $model->table('wx_autumn_wander_part_in')->where(array('open_id' => $this->openId, $autumnWanderModel->getTodayWhere()))->setDec('lotto_num');
        }
        if (in_array($this->prizeId, self::$prizeIdArr)) {  //抽中实物奖品
            $this->ajaxSuccess(self::$msg[10], 100, array('prizeId' => $this->prizeId, 'prize_name'=>$this->randPrizeArr['prize'],'recode_id' => $recode_id));
        } else {
            $this->ajaxError(self::$msg[11], -1100, array('prizeId' => 0));
        }
//
    }

    /**
     * @return mixed
     * @User: yfl
     * @Time: 2017年10月26日 14:05:24
     * @description: 保存抽奖记录
     */
    private function lottoRecodeWrite(Model $model)
    {
        $saveData['compass_id'] = $this->testComPassId;
        $saveData['open_id'] = $this->openId;
        $saveData['prize_id'] = isset($this->prizeId) ? $this->prizeId : 0;
        $saveData['prize_class'] = isset($this->randPrizeArr['name']) ? $this->randPrizeArr['name'] : '已经中过奖';
        $saveData['prize_name'] = isset($this->randPrizeArr['prize']) ? $this->randPrizeArr['prize'] : '谢谢惠顾';
        $saveData['create_time'] = time();

        return $recode_id = $model->table("wx_autumn_wander_recode")->add($saveData);
    }

    /**
     * @param AutumnWanderModel $autumnWanderModel
     * @return bool
     * @User: yfl
     * @Time: 2017年10月26日 12:40:08
     * @description:检测中奖的数量 是否有剩余量
     */
    private function verifyPrizeTotals(AutumnWanderModel $autumnWanderModel)
    {
        $where = array('prize_id' => $this->prizeId, 'prize_name' => $this->randPrizeArr['prize'], 'compass_id' => $this->testComPassId);

        $prizeRecodeNum = $autumnWanderModel->getPrizeRecodeNum($where);
        if ((int)$prizeRecodeNum >= (int)$this->randPrizeArr['total']) {
            $this->HandlePrize();
            return false;
        }
    }

    /**
     * @param AutumnWanderModel $autumnWanderModel
     * @return bool
     * @User: yfl
     * @Time:2017年10月26日 12:50:49
     * @description: 检测每天奖品的数量上限
     */
    private function verifyPrizePerDay(AutumnWanderModel $autumnWanderModel)
    {
        $map = array('prize_id' => $this->prizeId, 'prize_name' => $this->randPrizeArr['prize'], 'compass_id' => $this->testComPassId, 'TO_DAYS(FROM_UNIXTIME(create_time)) = TO_DAYS(NOW())');
        $prizeRecodeNumToday = $autumnWanderModel->getPrizeRecodeNum($map);
        if ((int)$prizeRecodeNumToday > (int)$this->randPrizeArr['perDay']) {
            $this->HandlePrize();
            return false;
        }
    }

    /**
     * @User: yfl
     * @Time: 2017年10月26日 11:08:08
     * @description: 中奖后处理中奖人信息
     */
    public function handelInfoAjax()
    {
        if (IS_AJAX && IS_POST) {
            //更新中奖用户的信息
            $model = new Model();
            $recode_id = htmlspecialchars(I('post.recode_id', ''), ENT_QUOTES);
            $post['name'] = htmlspecialchars(I('post.name', ''), ENT_QUOTES);
            $post['tel'] = htmlspecialchars(I('post.tel', ''), ENT_QUOTES);
            $post['address'] = htmlspecialchars(I('post.address', ''), ENT_QUOTES);
            $saveData["user_info"] = serialize($post);
            $saveData["status"] = 0;
            $res = $model->table("wx_autumn_wander_recode")->where(array('id' => $recode_id))->save($saveData);
            if ($res != false) {
                $this->ajaxSuccess(self::$msg[12]);
            } else {
                $this->ajaxError(self::$msg[13], -1300);
            }

        } else {
            $this->ajaxError(self::$msg[0]);
        }
    }

    /**
     * @param $proArr
     * @return int|string
     * @User: yfl
     * @Time: 2017年10月25日 18:19:53
     * @description: 获取随机奖品的key值
     */
    private function get_rand($proArr)
    {
        $result = "";
        $proSum = array_sum($proArr);
        foreach ($proArr as $key => $proCur) {
            $randNum = mt_rand(1, $proSum);
            if ($randNum <= $proCur) {
                $result = $key;
                break;
            } else {
                $proSum -= $proCur;
            }
        }
        if ($result == "") $this->get_rand($proArr);
        unset ($proArr);
        return $result;
    }

    /**
     * @param $openId :参与用户的微信openid
     * @return mixed
     * @User: yfl
     * @Time: 2017年10月25日 14:44:58
     * @description:获取今天可以投票的数量
     */
    private function getPoll($openId, AutumnWanderModel $autumnWanderModel)
    {

        $where = array('open_id' => $openId, "TO_DAYS(FROM_UNIXTIME(create_time)) = TO_DAYS(NOW())");
        return $dataArr = $autumnWanderModel->getPartInToday($where, 'poll');
    }

    /**
     * @param string $msg
     * @param int $code :错误代码
     * @param array $_data
     * @User: yfl
     * @Time: 2017年10月25日 14:26:03
     * @description:错误返回
     */
    protected function ajaxError($msg = '', $code = -1, array $_data = array())
    {
        header('Content-Type:application/json; charset=utf-8');
        $data = array('code' => $code, 'msg' => $msg, 'data' => $_data);
        exit(json_encode($data));
    }

    /**
     * @param $msg :消息
     * @param int $code : 错误代码
     * @param array $_data
     * @User: yfl
     * @Time: 2017年10月25日 14:26:16
     * @description:成功返回
     */
    protected function ajaxSuccess($msg, $code = 1, array $_data = array())
    {
        header('Content-Type:application/json; charset=utf-8');
        $data = array('code' => $code, 'msg' => $msg, 'data' => $_data);
        exit(json_encode($data));
    }

}


//<dl class="nowrap">
//    <dt>奖项<span style="font-size:20px;color:red;">1</span></dt>
//    <dd style="width:150px;" class="nowrap">
//       <input type="text" value="" class="textInput" name="prize[0][name]"/>
//    </dd>
//
//   <dd style="width:150px;" class="nowrap">
//   <input type="text" value="" class="textInput" name="prize[0][prize]"/>
//   </dd>
//
//   <dd style="width:150px;" class="nowrap">
//   <input type="text" value="" class="textInput" name="prize[0][total]"/>
//   </dd>
//
//   <dd style="width:150px;padding-left:35px;" class="nowrap">
//   <input type="text" value="" class="textInput" name="prize[0][pro]" size="10"/>
//   <span style="font-size:15px;margin-right:55px;">%</span>
//   </dd>
//
//    <dd style="width:150px;" class="nowrap">
//       <input type="text" value="" class="textInput" name="prize[0][perDay]"/>
//    </dd>
//
//    <dd style="width:80px;" class="nowrap">
//       <a href="javascript:void(0);" style="color:red;">默&nbsp;&nbsp;认</a>
//    </dd>
//</dl>

//$str='a:6:{i:0;a:5:{s:4:"name";s:9:"一等奖";s:5:"prize";s:12:"苹果手表";s:5:"total";s:1:"0";s:3:"pro";i:0;s:6:"perDay";s:1:"0";}i:1;a:5:{s:4:"name";s:9:"二等奖";s:5:"prize";s:12:"珠宝首饰";s:5:"total";s:1:"0";s:3:"pro";i:0;s:6:"perDay";s:1:"0";}i:2;a:5:{s:4:"name";s:9:"三等奖";s:5:"prize";s:12:"谢谢参与";s:5:"total";s:7:"9999999";s:3:"pro";i:99;s:6:"perDay";s:5:"99999";}i:3;a:5:{s:4:"name";s:9:"四等奖";s:5:"prize";s:18:"星巴克保温杯";s:5:"total";s:1:"0";s:3:"pro";i:0;s:6:"perDay";s:1:"0";}i:4;a:5:{s:4:"name";s:9:"五等奖";s:5:"prize";s:8:"VR眼镜";s:5:"total";s:1:"0";s:3:"pro";i:0;s:6:"perDay";s:1:"0";}i:5;a:5:{s:4:"name";s:9:"六等奖";s:5:"prize";s:9:"旅游卡";s:5:"total";s:2:"10";s:3:"pro";i:1;s:6:"perDay";s:1:"1";}}';
//<pre>array(6) {
//    [0]=>
//  array(5) {
//        ["name"]=>
//    string(9) "一等奖"
//        ["prize"]=>
//    string(12) "苹果手表"
//        ["total"]=>
//    string(1) "0"
//        ["pro"]=>
//    int(0)
//    ["perDay"]=>
//    string(1) "0"
//  }
//  [1]=>
//  array(5) {
//        ["name"]=>
//    string(9) "二等奖"
//        ["prize"]=>
//    string(12) "珠宝首饰"
//        ["total"]=>
//    string(1) "0"
//        ["pro"]=>
//    int(0)
//    ["perDay"]=>
//    string(1) "0"
//  }
//  [2]=>
//  array(5) {
//        ["name"]=>
//    string(9) "三等奖"
//        ["prize"]=>
//    string(12) "谢谢参与"
//        ["total"]=>
//    string(7) "9999999"
//        ["pro"]=>
//    int(99)
//    ["perDay"]=>
//    string(5) "99999"
//  }
//  [3]=>
//  array(5) {
//        ["name"]=>
//    string(9) "四等奖"
//        ["prize"]=>
//    string(18) "星巴克保温杯"
//        ["total"]=>
//    string(1) "0"
//        ["pro"]=>
//    int(0)
//    ["perDay"]=>
//    string(1) "0"
//  }
//  [4]=>
//  array(5) {
//        ["name"]=>
//    string(9) "五等奖"
//        ["prize"]=>
//    string(8) "VR眼镜"
//        ["total"]=>
//    string(1) "0"
//        ["pro"]=>
//    int(0)
//    ["perDay"]=>
//    string(1) "0"
//  }
//  [5]=>
//  array(5) {
//        ["name"]=>
//    string(9) "六等奖"
//        ["prize"]=>
//    string(9) "旅游卡"
//        ["total"]=>
//    string(2) "10"
//        ["pro"]=>
//    int(1)
//    ["perDay"]=>
//    string(1) "1"
//  }
//}

